﻿@model RichTextContent
@{
    // add content
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Scripts/Proggy.CorePropertyTypes.js", BackEndContentType.JavaScript);
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Scripts/Proggy.CorePropertyTypes.DragAndDrop.js", BackEndContentType.JavaScript);
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/ThirdParty/tiny_mce/jquery.tinymce.js", BackEndContentType.JavaScript);
    Html.AddToBackEndContent("~/Areas/ProggyCore/Content/Scripts/Proggy.CorePropertyTypes.Rte.js", BackEndContentType.JavaScript);
    Html.RenderBackEndContentForLightboxPartial();

    // get config object
    var configObject = Model.GetConfigObject<RichTextContentConfigObject>();

    // get text area prop
    var textAreaId = Model.PropertyNameStart + "_SavedValue";
    var textAreaName = Model.PropertyNameStart + ".SavedValue";
    var configObjectText = configObject.GetJsonString();
    
    // get value
    var htmlValue = Model.SavedValue;//HttpUtility.HtmlDecode(Model.SavedValue);
    
    
}
<noscript><div class="proggy-noscript">THIS EDITOR WILL NOT WORK WITHOUT JAVASCRIPT TURNED ON AND IT WOULD BE DANGEROUS TO USE THE EDITOR WHILST JAVASCRIPT IS TURNED OFF. PLEASE TURN JAVASCRIPT ON.</div></noscript>
<div style="margin-left: -1px">
    <textarea id="@(textAreaId)" name="@(textAreaName)">
        @Html.Raw(htmlValue)
    </textarea>    
</div>
<script type="text/javascript">
    
    // get id 
    var id = "@textAreaId";

    // get json
    var json = '@(MvcHtmlString.Create(configObjectText))';

    // start rte
    var rte = undefined;

    // do loop
    Proggy.Static.WaitForTypesToRegister(function () {

        // get rte object
        var rte = new Proggy.CorePropertyTypes.Rte();
        rte.Init(id, json);

    });
</script>
